#include <bits/stdc++.h>
using namespace std;
int t, n;
int a[200005];
bool b[200005];
int ans;
int qh()
{
    int s = 0;
    for (int i = 1;i <= n;i++)
    {
        for (int j = i - 1;j >= 1;j--)
        {
            if (b[i] == b[j])
            {
                if (a[i] == a[j])
                    s += a[i];
                break;
            }
        }
    }
    return s;
}
void f(int x)
{
    if (x == n)
    {
        ans = max(ans, qh());
        return ;
    }
    b[x + 1] = 1;
    f(x + 1);
    b[x + 1] = 0;
    f(x + 1);
    return ;
}
int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    scanf("%d", &t);
    while (t--)
    {
        ans = 0;
        scanf("%d", &n);
        for (int i = 1;i <= n;i++)
        {
            scanf("%d", a + i);

        }
        f(0);
        printf("%d\n", ans);
    }
    return 0;
}